<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------

namespace app\api\model;

class Goods extends ApiBase
{
    public function getGoodsThumbAttr($value, $data)
    {
        if ($value && !preg_match('/^http(s)?:\\/\\/.+/', $value)) {
            return SITE_PATH . $value;
        } else {
            return $value;
        }
    }
    public function getGoodsPhoto(){
    	return $this->hasMany("GoodsPhoto","goods_id");
    }
    public function getContentAttr($value){
    	return preg_replace("/src=\"(\/data\/uploads\/)(.*?)\"\/>/i", "src=\"".SITE_PATH."$1$2\"/>", $value);
    }
}